import random
import numpy as np
import torch
try:
    import torch_npu
    npu_available = True
except:
    npu_available = False
import transformers


def seed_everything(seed=0) -> None:
    """Set random seeds for reproducibility."""
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = True
    transformers.set_seed(seed)
    if npu_available:
        torch_npu.npu.manual_seed(seed)
        torch_npu.npu.manual_seed_all(seed)
